package com.zb.select.controller;

import com.zb.entity.SelectVo;
import com.zb.network.service.ConNetworkAuthenFieldService;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.*;
import com.zb.utils.TokenUtil;
import com.zb.vo.NetworkSelectSearchVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @Author WEN
 * @Date 2023/9/11 0011
 **/
@Api(tags = "服务商下拉类接口")
@RestController
@RequestMapping("/networkSelect")
public class NetworkSelectController {
    @Resource
    private ZjNetworkTypeService networkTypeService;
    @Resource
    private ZjNetworkEmpTypeService networkEmpTypeService;
    @Resource
    private ZjNetworkFieldService networkFieldService;
    @Resource
    private ZjNetworkEmpFieldService networkEmpFieldService;
    @Resource
    private ZjNetworkService networkService;
    @Resource
    private ZjNetworkEmpService networkEmpService;
    @Resource
    private ZjNetworkEmpLevelService networkEmpLevelService;
    @Resource
    private ZjNetworkEmpSkillService networkEmpSkillService;
    @Resource
    private ZjNetworkEmpBandService networkEmpBandService;

    @ApiOperation("分页获取服务商类型下拉数据")
    @PostMapping("/networkTypePageSelect")
    public Result networkTypePageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商类型下拉数据成功").data(networkTypeService.networkTypePageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取服务商人员类型下拉数据")
    @PostMapping("/networkEmpTypePageSelect")
    public Result networkEmpTypePageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商级别下拉数据成功").data(networkEmpTypeService.networkEmpTypePageSelect(custAccId, selectVo));
    }

    @ApiOperation("获取服务商字段下拉数据")
    @GetMapping("/networkFieldSelect")
    public Result networkFieldSelect(HttpServletRequest request) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商字段下拉数据成功").data(networkFieldService.networkFieldSelect(custAccId));
    }

    @ApiOperation("获取工程师字段下拉数据")
    @GetMapping("/networkEmpFieldSelect")
    public Result networkEmpFieldSelect(HttpServletRequest request) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取工程师字段下拉数据").data(networkEmpFieldService.getNetworkEmpCustomFields(custAccId, false));
    }

    @ApiOperation("获取所有服务商下拉数据")
    @PostMapping("/getNetworkPageSelect")
    public Result getNetworkPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取所有服务商下拉数据成功").data(networkService.getNetworkPageSelect(custAccId, null, selectVo));
    }

    @ApiOperation("根据服务商分类或区域查询对应的服务商")
    @PostMapping("/getNetworkSelect")
    public Result getNetworkSelect(HttpServletRequest request, @RequestBody @Valid NetworkSelectSearchVo searchVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商下拉数据成功").data(networkService.getNetworkSelect(custAccId, searchVo));
    }

    @ApiOperation("获取销售服务商下拉数据")
    @PostMapping("/getSaleNetworkPageSelect")
    public Result getSaleNetworkPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取销售服务商下拉数据成功").data(networkService.getNetworkPageSelect(custAccId, 1, selectVo));
    }

    @ApiOperation("获取售后服务商下拉数据")
    @PostMapping("/getAfterSaleNetworkPageSelect")
    public Result getAfterSaleNetworkPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取售后服务商下拉数据成功").data(networkService.getNetworkPageSelect(custAccId, 2, selectVo));
    }

    @ApiOperation("获取服务商人员下拉数据")
    @PostMapping("/getNetworkEmpPageSelect/{networkId}")
    public Result getNetworkEmpPageSelect(@PathVariable @ApiParam(value = "服务商ID", required = true) Long networkId, @RequestBody SelectVo selectVo) {
        return Result.success("获取服务商人员下拉数据成功").data(networkEmpService.getNetworkEmpPageSelect(networkId, selectVo));
    }

    @ApiOperation("根据商家获取服务人员下拉数据")
    @PostMapping("/getNetworkEmpSelect")
    public Result getNetworkEmpPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success().data(networkEmpService.getNetworkEmpSelect(custAccId, selectVo));
    }

    @ApiOperation("根据服务人员ID获取对应服务商下拉数据")
    @GetMapping("/getNetworkByNetworkEmpIdSelect/{networkEmpId}")
    public Result getNetworkByNetworkEmpIdSelect(HttpServletRequest request, @PathVariable @ApiParam(value = "服务人员ID", required = true) Long networkEmpId) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success().data(PageUtil.rows(networkService.getNetworkByNetworkEmpIdSelect(custAccId, networkEmpId)));
    }

    @ApiOperation("获取服务商及地址下拉数据")
    @PostMapping("/getNetworkAddressPageSelect")
    public Result getNetworkAddressPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商及地址下拉数据成功").data(networkService.getNetworkAddressPageSelect(custAccId, selectVo));
    }

    @ApiOperation("获取服务商人员及地址下拉数据")
    @PostMapping("/getNetworkEmpAddressPageSelect")
    public Result getNetworkEmpAddressPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商人员及地址下拉数据成功").data(networkEmpService.getNetworkEmpAddressPageSelect(custAccId, selectVo));
    }

    @ApiOperation("获取服务商人员等级下拉数据")
    @PostMapping("/getNetworkEmpLevelSelect")
    public Result getNetworkEmpLevelSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商人员等级下拉数据成功").data(networkEmpLevelService.getNetworkEmpLevelSelect(custAccId, selectVo));
    }

    @ApiOperation("获取服务商人员技能下拉数据")
    @PostMapping("/getNetworkEmpSkillSelect")
    public Result getNetworkEmpSkillSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取服务商人员技能下拉数据成功").data(networkEmpSkillService.getNetworkEmpSkillSelect(custAccId, selectVo));
    }

    @ApiOperation("获取服务人员银行卡")
    @PostMapping("/getNetworkBandSelect/{networkEmpId}")
    public Result getNetworkBandSelect(@PathVariable @ApiParam(value = "服务人员ID", required = true) Long networkEmpId) {
        return Result.success("获取服务人员银行卡成功").data(PageUtil.rows(networkEmpBandService.getNetworkEmpBandSelect(networkEmpId)));
    }




}
